<?php
/**
 * 活动设备列表
 */
namespace Home\Model; 
use Think\Model;
class ActivityModel extends  Model{
     /**
      * 活动设备搜索
      */
    public function index($arg)
    { 
      $page=!empty($arg['page']) ?intval($arg['page']):1;
     // $activity=M('activity_device a');
     $where=array();
     if(!empty($arg['activityid'])){
        $where['a.activityid']=intval($arg['activityid']);
     }
    $count=M('activity_device a')->count();
    $pagearr= getPageArr($page,C('PAGESIZE'),$count);
    $result=M('activity_device a')
    ->join('cart_device b on a.deviceid=b.deviceid')
    ->where($where)
    ->limit($pagearr['start'],$pagearr['pagesize'])
    ->getField("a.id,a.activityid,a.deviceid,b.devicecode");
    
    foreach ($result as $key => $value) 
    {
      $result[$key]['activityid']=M('activity')->where("id='%d'",$value['activityid'])->getField("parenttheme");
    }
     $temp['pagearr']=$pagearr;
    $temp['devices']=!empty($result)?$result:'';
    return $temp;


}
}